from django import forms


class ProjectDefectReportViewForm(forms.Form):
    action_type = forms.ChoiceField(label='动作类型', choices=((0, '关闭报告'), (1, '立即响应'), (2, '确认完成')), required=True)
    pk = forms.IntegerField(label='ID', required=True)

    def get_errors(self):
        errors = self.errors.get_json_data()
        new_errors = {}
        for key, message_dicts in errors.items():
            messages = []
            for message in message_dicts:
                messages.append(message['message'])
            new_errors[key] = messages
        return new_errors
